/*
ID: icerupt1
PROG: ariprog
LANG: C++11
*/
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int const maxm = 251*251*2;
bool bisquare[maxm];
int n, m;

struct data { int a, b; };

bool is_square(int x)
{
	int t = sqrt(x);
	if (t > m) return false;
	return t*t == x;
}

bool is_bisquare(int x)
{
	for (int i = 0; i*i*2 <= x; i++)
		if (is_square(x-i*i)) return true;
	return false;
}

void get_bisquare(int m)
{
	for (int i = 0; i <= m; i++)
		bisquare[i] = is_bisquare(i);
}

int main()
{
	ifstream fin {"ariprog.in" };
	ofstream fout{"ariprog.out"};

	fin >> n >> m;
	vector<data> ans;
	int max_num = m*m + m*m;
	get_bisquare(max_num);
	for (int b = 1; (n-1)*b <= max_num; b++) {
		int f[max_num+1];
		fill(f, f+max_num+1, 0);
		for (int i = 0; i <= max_num; i++)
			if (bisquare[i]) {
				if (i+b <= max_num) f[i + b] = f[i] + 1;
				if (f[i] >= n-1) ans.push_back({i-(n-1)*b, b});
			}
	}
	if (ans.size() == 0)
		fout << "NONE\n";
	else
		for (auto v:ans) fout << v.a << " " << v.b << "\n";
}
